import java.awt.*;

public class TextObject implements IDrawingObject{
	Point startingPosition;
	Color myColor;
	String mytext;
	Font font;
	
	public TextObject(Point p, Color c, Font f){
		startingPosition=p;
		myColor=c;
		this.font=f;
		mytext="";
	}

	public void setText(String s){
		mytext=s;
	}
	
	public void drawMe(Graphics g) {
		g.setFont(font);
		Color tempColor = g.getColor();
		g.setColor(myColor);
		g.drawString(mytext, startingPosition.x,startingPosition.y); 
		g.setColor(tempColor);
	}

	public boolean isPointInObject(Point p) {
		return p.x<=getLeft()+getWidth() && p.x>=getLeft() && p.y>=getTop() && p.y<=getTop()+getHeight();
	}

	@SuppressWarnings("deprecation")
	public int getHeight() {
		return Toolkit.getDefaultToolkit().getFontMetrics(font).getHeight();
	}

	public int getLeft() {
		// TODO Auto-generated method stub
		return startingPosition.x;
	}

	public int getTop() {
		// TODO Auto-generated method stub
		return startingPosition.y-getHeight()*2/3;
	}

	@SuppressWarnings("deprecation")
	public int getWidth() {
		// TODO Auto-generated method stub
		return Toolkit.getDefaultToolkit().getFontMetrics(font).stringWidth(mytext);
	}
	public void setmycolor(Color c){
		myColor=c;
	}
}
